package app.netant.book.zw34;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
import app.netant.book.base.BaseEntity;
import app.netant.book.base.BasePage;
import cn.lily.com.enviroment.Enviroment;

public class Zw34Page extends BasePage {

	public Zw34Page(String netSite) {
		super(netSite);
		this.tableKey = "zw34";
		this.selectKey = "body .colum .booklist ul li span.fs a";
		this.preHref = "https://www.34zw.net";
	}

	@Override
	public String buildHref(Element element) {
		String href = element.attr("href");
		return href;
	}

	@Override
	public BaseEntity buildEntity() {
		return new Zw34Entity();
	}

	@Override
	public BaseDetail buildDetail(String href) {
		return new Zw34Detail(href);
	}

	@Override
	public void afterEntity(BaseEntity entity, Element element) {
		
		Element li = element.parent().parent();
		Elements tds = li.select("span");
		
		if(tds.size()>6){
			String title = tds.get(0).text();
			String writer = tds.get(2).text();
			String size = tds.get(3).text();
			String date = tds.get(4).text();
			String state = tds.get(5).text();
			
			entity.setNovelName(title);
			entity.setNovelFullName(title+".txt");
			entity.setNovelWriter(writer);
			entity.setNovelDate(date);
			entity.setNovelState(state);
			entity.setNovelSize(size);
			
		}
		
	}

	
	public static void main(String[] args) {
		Enviroment.createEnv();
		Enviroment.getEnv().getLogBean().beginLog();
		Zw34Page page = new Zw34Page("https://www.34zw.net/xuanhuan/");
		page.analyseHref();
	}
	
}
